Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors MinimalIamCredentialsRestStub to properly handle potential errors when retrieving the universe domain, updating IamCredentialsEndpoint and MakeRequestPath to return StatusOr<std::string> and adding corresponding unit tests for failure paths. A review comment suggests passing universe_domain by const& in IamCredentialsEndpoint to avoid unnecessary copies or moves of the StatusOr and its underlying string, which aligns with the repository's optimization guidelines.
| StatusOr<std::string> IamCredentialsEndpoint( | ||
| StatusOr<std::string> universe_domain) { | ||
| if (!universe_domain) return std::move(universe_domain).status(); | ||
| return absl::StrCat("https://iamcredentials.", *universe_domain); | ||
| } |
There was a problem hiding this comment.
Passing StatusOr<std::string> by value to IamCredentialsEndpoint causes unnecessary moves/copies of the underlying std::string when the function is called. Since absl::StrCat only reads the string, we can pass universe_domain by const& to avoid any overhead of moving or copying the StatusOr or its contained string.
StatusOr<std::string> IamCredentialsEndpoint(
StatusOr<std::string> const& universe_domain) {
if (!universe_domain) return universe_domain.status();
return absl::StrCat("https://iamcredentials.", *universe_domain);
}References
- Scrutinize copies of non-fundamental C++ types. Is it necessary to copy the data? Can we move the data instead? (link)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16699 +/- ##
==========================================
+ Coverage 92.74% 92.76% +0.01%
==========================================
Files 2271 2271
Lines 227219 227288 +69
==========================================
+ Hits 210734 210833 +99
+ Misses 16485 16455 -30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
No description provided.